#include "rbtree.h"

int compareFunc(void * val1, void* val2)
{
    int A = *(int*)val1;
    int B = *(int*)val2;

    if(A > B)
    {
        return 1;
    }
    else if(A < B)
    {
        return -1;
    }
    else
    {
        return 0;
    }
}

void printFunc(void* val)
{
    printf("%d  ", *(int*)val);
}

int main()
{
    // int a = 10;
    RB_TREE* rbtree = NULL;
    RBTree_Init(&rbtree, compareFunc, printFunc); 
    // RBTree_Insert(rbtree, (void*)&a);
    int*A = malloc(sizeof(int) * 10);
    
    for(int idx = 0; idx < 10; idx++)
    {
        A[idx] = idx;
        RBTree_Insert(rbtree, (void*)&A[idx]);
        RBTree_LevelOrder(rbtree);
    }
    for(int idx = 0; idx < 10; idx++)
    {
        A[idx] = idx;
        RBTree_Delete(rbtree, (void*)&A[idx]);
        RBTree_LevelOrder(rbtree);
    }
    free(A);
    int b = 1;

    // void* c = RBTree_Search(rbtree, (void*)&b);

    //RBTree_Delete(rbtree, (void*)&b);

    void* c = RBTree_Search(rbtree, (void*)&b);
    if(c != NULL)
    {
        printf("---\n");
    }
    RBTree_LevelDestroy(rbtree);
    return 0;
}